package com.wl.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.wl.entity.Car;
import com.wl.service.CarService;
import com.wl.service.MetricService;
import org.mybatis.spring.SqlSessionTemplate;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;

@RestController
@RequestMapping("test")
public class TestController {

    @Resource
    private SqlSessionTemplate sqlSessionTemplate;

    @Resource
    private MetricService metricService;

    @Resource
    private CarService carService;

    @GetMapping("list")
    public List<Car> list(){
        return carService.list();
    }

    @GetMapping("search3")
    public IPage<Map<String, Object>> search3(){
        IPage<Map<String, Object>> page = Page.of(1,10);
        Map<String,Object> params = new HashMap<>();
        params.put("page",page);
        List<Map<String,Object>> objects = sqlSessionTemplate.selectList("top.nz.dao.UserMapper.search3", params);
        page.setRecords(objects);
        return page;
    }
}
